package com.oracle.application.service.impl;

import com.oracle.application.service.MailService;
import com.oracle.application.util.RedisUtil;
import com.oracle.application.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;


/**
 * @Author 李源浩
 * @Date 2021/7/8 14:23
 * @Version 1.0
 */
@Service
public class MailServiceImpl implements MailService {

    @Autowired
    private JavaMailSender javaMailSender;

    @Autowired
    private RedisUtil redisUtil;


    @Override
    public boolean checkedRandom(String email, String requestRandom) {
        System.out.println("service");
            //邮件对象
            SimpleMailMessage emai = new SimpleMailMessage();
            emai.setFrom("lyh_1073055861qq@163.com");//源发送地址
            emai.setTo(email);//目标地址
            emai.setSubject("验证码");
            emai.setText("验证码是"+requestRandom+","+redisUtil.getExpire("ym")+"秒后失效");
            javaMailSender.send(emai);//执行发送
        //return new R(200,"发送成功",null);
        return true;
    }
}
